﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test6-3.aspx.cs" Inherits="Web_Project.test6_3" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <style type="text/css">
        .auto-style1 {
            width: 304px;
        }
        .auto-style2 {
            height: 25px;
        }
        .auto-style3 {
            height: 34px;
        }
    </style>
    <script type="text/javascript">
        function confirmDelete() {
            return confirm("您确定要删除这个商品吗？\n此操作不可恢复！");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" SelectCommand="SELECT * FROM [Cartoon]"></asp:SqlDataSource>
            <br />
            <br />
            <div>
                <div style="float:left;width:30%;margin-top:20px;">
                <asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ct_name" DataValueField="ct_id">
                </asp:BulletedList>
                </div>
                <div style="float:left;width:30%;margin-top:20px;">
                    <asp:CheckBoxList ID="CheckBoxList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ct_name" DataValueField="ct_id">
                    </asp:CheckBoxList>
                </div>
            </div>
            <div>
                <div style="float:left;width:30%;margin-top:20px;">
                    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ct_name" DataValueField="ct_id">
                    </asp:DropDownList>
                </div>
                <div style="float:left;width:30%;margin-top:20px;">
                    <asp:ListBox ID="ListBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ct_name" DataValueField="ct_id"></asp:ListBox>
                </div>
            </div>
            <div>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ct_name" DataValueField="ct_id">
                </asp:RadioButtonList>
            </div>
            <br />
            <div>
                <br />
                <br />
                <table>
                    <tr>
                        <td colspan="2" class="auto-style1">分类名称：
                            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="auto-style1">
                            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="添加分类" />
                            &nbsp;<asp:Button ID="Button2" runat="server" Text="删除" OnClick="Button2_Click" />
                            &nbsp;
                            <asp:Button ID="Button3" runat="server" Text="修改分类" OnClick="Button3_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="auto-style1">
                            <asp:ListBox ID="ListBox2" runat="server" DataSourceID="SqlDataSource2" DataTextField="Name" DataValueField="ct_CategoryId" OnSelectedIndexChanged="ListBox2_SelectedIndexChanged" Width="162px" AutoPostBack="True"></asp:ListBox>
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" DeleteCommand="DELETE FROM [ctCategory] WHERE [ct_CategoryId] = @ct_CategoryId" InsertCommand="INSERT INTO [ctCategory] ([Name]) VALUES (@Name)" SelectCommand="SELECT * FROM [ctCategory]" UpdateCommand="UPDATE [ctCategory] SET [Name] = @Name WHERE [ct_CategoryId] = @ct_CategoryId">
                                <DeleteParameters>
                                    <asp:ControlParameter ControlID="ListBox2" Name="ct_CategoryId" PropertyName="SelectedValue" Type="Int32" />
                                </DeleteParameters>
                                <InsertParameters>
                                    <asp:ControlParameter ControlID="TextBox1" Name="Name" PropertyName="Text" Type="String" />
                                </InsertParameters>
                                <UpdateParameters>
                                    <asp:ControlParameter ControlID="TextBox1" Name="Name" PropertyName="Text" Type="String" />
                                    <asp:ControlParameter ControlID="ListBox2" Name="ct_CategoryId" PropertyName="SelectedValue" Type="Int32" />
                                </UpdateParameters>
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style1"><asp:Label ID="Label1" runat="server"></asp:Label></td>
                    </tr>
                </table>
                <br />
                <br />
                <table>
                    <tr>
                        <td>选择商品：</td>
                        <td>
                            <asp:DropDownList ID="DropDownList2" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource3" DataTextField="Name" DataValueField="ProductId" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
                            </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" DeleteCommand="DELETE FROM [Product] WHERE [ProductId] = @ProductId" InsertCommand="INSERT INTO [Product] ([CategoryId], [ListPrice], [UnitCost], [SuppId], [Name], [Descn], [Image], [Qty]) VALUES (@CategoryId, @ListPrice, @UnitCost, @SuppId, @Name, @Descn, @Image, @Qty)" SelectCommand="SELECT * FROM [Product]" UpdateCommand="UPDATE [Product] SET [CategoryId] = @CategoryId, [ListPrice] = @ListPrice, [UnitCost] = @UnitCost, [SuppId] = @SuppId, [Name] = @Name, [Descn] = @Descn, [Image] = @Image, [Qty] = @Qty WHERE [ProductId] = @ProductId">
                    <DeleteParameters>
                        <asp:ControlParameter ControlID="DropDownList2" Name="ProductId" PropertyName="SelectedValue" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:ControlParameter ControlID="DropDownList3" Name="CategoryId" PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="TextBox2" Name="ListPrice" PropertyName="Text" Type="Decimal" />
                        <asp:ControlParameter ControlID="TextBox3" Name="UnitCost" PropertyName="Text" Type="Decimal" />
                        <asp:ControlParameter ControlID="DropDownList4" Name="SuppId" PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="TextBox4" Name="Name" PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="TextBox5" Name="Descn" PropertyName="Text" Type="String" />
                        <asp:Parameter Name="Image" Type="String" />
                        <asp:ControlParameter ControlID="TextBox6" Name="Qty" PropertyName="Text" Type="Int32" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:ControlParameter ControlID="DropDownList3" Name="CategoryId" PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="TextBox2" Name="ListPrice" PropertyName="Text" Type="Decimal" />
                        <asp:ControlParameter ControlID="TextBox3" Name="UnitCost" PropertyName="Text" Type="Decimal" />
                        <asp:ControlParameter ControlID="DropDownList4" Name="SuppId" PropertyName="SelectedValue" Type="Int32" />
                        <asp:ControlParameter ControlID="TextBox4" Name="Name" PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="TextBox5" Name="Descn" PropertyName="Text" Type="String" />
                        <asp:Parameter Name="Image" Type="String" />
                        <asp:ControlParameter ControlID="TextBox6" Name="Qty" PropertyName="Text" Type="Int32" />
                        <asp:ControlParameter ControlID="DropDownList2" Name="ProductId" PropertyName="SelectedValue" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>分类：</td>
                        <td>
                            <asp:DropDownList ID="DropDownList3" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource4" DataTextField="Name" DataValueField="CategoryId">
                            </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" DeleteCommand="DELETE FROM [Category] WHERE [CategoryId] = @CategoryId" InsertCommand="INSERT INTO [Category] ([Name], [Descn]) VALUES (@Name, @Descn)" SelectCommand="SELECT * FROM [Category]" UpdateCommand="UPDATE [Category] SET [Name] = @Name, [Descn] = @Descn WHERE [CategoryId] = @CategoryId">
                    <DeleteParameters>
                        <asp:Parameter Name="CategoryId" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Descn" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Descn" Type="String" />
                        <asp:Parameter Name="CategoryId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>价格：</td>
                        <td>
                            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>单价：</td>
                        <td>
                            <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>供应商：</td>
                        <td>
                            <asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource5" DataTextField="Name" DataValueField="SuppId">
                            </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSource5" runat="server" ConnectionString="<%$ ConnectionStrings:mfd_severConnectionString %>" DeleteCommand="DELETE FROM [Supplier] WHERE [SuppId] = @SuppId" InsertCommand="INSERT INTO [Supplier] ([Name], [Addr1], [Addr2], [City], [State], [Zip], [Phone]) VALUES (@Name, @Addr1, @Addr2, @City, @State, @Zip, @Phone)" SelectCommand="SELECT * FROM [Supplier]" UpdateCommand="UPDATE [Supplier] SET [Name] = @Name, [Addr1] = @Addr1, [Addr2] = @Addr2, [City] = @City, [State] = @State, [Zip] = @Zip, [Phone] = @Phone WHERE [SuppId] = @SuppId">
                    <DeleteParameters>
                        <asp:Parameter Name="SuppId" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Addr1" Type="String" />
                        <asp:Parameter Name="Addr2" Type="String" />
                        <asp:Parameter Name="City" Type="String" />
                        <asp:Parameter Name="State" Type="String" />
                        <asp:Parameter Name="Zip" Type="String" />
                        <asp:Parameter Name="Phone" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="Addr1" Type="String" />
                        <asp:Parameter Name="Addr2" Type="String" />
                        <asp:Parameter Name="City" Type="String" />
                        <asp:Parameter Name="State" Type="String" />
                        <asp:Parameter Name="Zip" Type="String" />
                        <asp:Parameter Name="Phone" Type="String" />
                        <asp:Parameter Name="SuppId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td>商品名称：</td>
                        <td>
                            <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style2">商品简介：</td>
                        <td class="auto-style2">
                            <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td>图片：</td>
                        <td>
                            <asp:Image ID="Image1" runat="server" />
                            <asp:FileUpload ID="FileUpload1" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>数量：</td>
                        <td>
                            <asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="auto-style3">利用数据源控件：</td>
                        <td class="auto-style3">
                            <asp:Button ID="Button4" runat="server" Text="添加商品" OnClick="Button4_Click" />
&nbsp;<asp:Button ID="Button5" runat="server" Text="修改商品" OnClick="Button5_Click" />
&nbsp;<asp:Button ID="Button6" runat="server" Text="删除商品" OnClick="Button6_Click" OnClientClick="return confirmDelete();" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <asp:Label ID="Label2" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</body>
</html>
